home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 551-575 / disk_562 / intuisup / render / source.lzh / render_test.c < prev    next >
C/C++ Source or Header  |  1991-10-19  |  3KB  |  118 lines

  1.         /*************************************
  2.          *                                   *
  3.          *            Gadgets v2.0           *
  4.          *   by Torsten Jürgeleit in 05/91   *
  5.          *                                   *
  6.          *            Test program           *
  7.          *                                   *
  8.          *************************************/
  9.  
  10.     /* Includes */
  11.  
  12. #include <exec/types.h>
  13. #include <graphics/gfxbase.h>
  14. #include <graphics/text.h>
  15. #include <exec/types.h>
  16. #include <intuition/intuition.h>
  17. #include <functions.h>
  18. #include <string.h>
  19. #include "render.h"
  20.  
  21.     /* Defines */
  22.  
  23. #define WINDOW_WIDTH        600
  24. #define WINDOW_HEIGHT        200
  25. #define WINDOW_TITLE        (UBYTE *)" Render test "
  26.  
  27. #define RENDER_INFO_FLAGS    (USHORT)(RENDER_INFO_FLAG_INNER_WINDOW | RENDER_INFO_FLAG_BACK_FILL)
  28. #define OPEN_WINDOW_FLAGS    (USHORT)(OPEN_WINDOW_FLAG_CENTER_WINDOW | OPEN_WINDOW_FLAG_RENDER_PENS)
  29.  
  30.     /* Globals */
  31.  
  32. struct IntuitionBase  *IntuitionBase;
  33. struct GfxBase        *GfxBase;
  34.  
  35.     /* Statics */
  36.  
  37. STATIC struct NewWindow  test_new_window = { 0, 0, WINDOW_WIDTH,
  38.    WINDOW_HEIGHT, 0, 1, CLOSEWINDOW, WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH |
  39.    SMART_REFRESH | NOCAREREFRESH | RMBTRAP | ACTIVATE, NULL, NULL,
  40.    WINDOW_TITLE, NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN };
  41. STATIC struct TextAttr  topaz60_attr = { (STRPTR)"topaz.font", TOPAZ_SIXTY,
  42.                            FS_NORMAL, FPF_ROMFONT };
  43. STATIC struct IntuiText  itexts[] = {
  44.    {
  45.     0, 0, JAM1, (WINDOW_WIDTH - 10 * 10) / 2, (WINDOW_HEIGHT - 6 * 8) / 2,
  46.     &topaz60_attr, (UBYTE *)"Text pen 1", &itexts[1]
  47.    }, {
  48.     0, 0, JAM1, (WINDOW_WIDTH - 10 * 10) / 2, (WINDOW_HEIGHT + 4 * 8) / 2,
  49.     &topaz60_attr, (UBYTE *)"Text pen 2", NULL
  50.    }
  51. };
  52.     /* Prototypes */
  53.  
  54. VOID test_action(struct RenderInfo  *ri, struct Window  *win);
  55.  
  56.     /* Pragmas */
  57.  
  58. #pragma regcall(test_action(a0,a1))
  59.  
  60.     /* Render test */
  61.  
  62.    LONG
  63. main(VOID)
  64. {
  65.    struct RenderInfo  *ri;
  66.    struct Window      *win;
  67.  
  68.    if (IntuitionBase = OpenLibrary("intuition.library", 0L)) {
  69.       if (GfxBase = OpenLibrary("graphics.library", 0L)) {
  70.      if (ri = get_render_info(NULL, RENDER_INFO_FLAGS)) {
  71.         if (win = open_window(ri, &test_new_window, OPEN_WINDOW_FLAGS)) {
  72.            test_action(ri, win);
  73.            CloseWindow(win);
  74.         }
  75.         free_render_info(ri);
  76.      }
  77.      CloseLibrary(GfxBase);
  78.       }
  79.       CloseLibrary(IntuitionBase);
  80.    }
  81.    return(0L);
  82. }
  83.     /* Perform IDCMP action */
  84.  
  85.    VOID
  86. test_action(struct RenderInfo  *ri, struct Window  *win)
  87. {
  88.    struct RastPort      *rp = win->RPort;
  89.    struct MsgPort       *up = win->UserPort;
  90.    struct Image         *image = &ri->ri_Images[0];
  91.    struct IntuiMessage  *msg;
  92.    ULONG  left_edge = 40;
  93.    USHORT i;
  94.    BOOL   keepon = TRUE;
  95.  
  96.    /* Init and print intui texts */
  97.    itexts[0].FrontPen = ri->ri_TextPen1;
  98.    itexts[1].FrontPen = ri->ri_TextPen2;
  99.    PrintIText(rp, &itexts[0], 0L, 0L);
  100.  
  101.    /* Print render images */
  102.    for (i = 0; i < MAX_RENDER_IMAGES; i++, image++, left_edge += 50) {
  103.       DrawImage(rp, image, left_edge, (LONG)((WINDOW_HEIGHT -
  104.                 (2 * image->TopEdge + image->Height)) / 2));
  105.    }
  106.  
  107.    /* Waiting for close window event */
  108.    do {
  109.       WaitPort(up);
  110.       while (msg = (struct IntuiMessage *)GetMsg(up)) {
  111.      if (msg->Class == CLOSEWINDOW) {
  112.         keepon = FALSE;
  113.      }
  114.      ReplyMsg((struct Message *)msg);
  115.       }
  116.    } while (keepon == TRUE);
  117. }
  118.